package vn.keho.module.dompeto.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import com.mobeta.android.dslv.DragSortController;

import java.util.List;

import vn.keho.module.dompeto.MerchantActivity;
import vn.keho.module.dompeto.model.ChannelModel;
import vn.keho.module.dompeto.utils.ThemeUtil;

public class DSLVFragmentClicks extends DSLVFragment {

    public static DSLVFragmentClicks newInstance(List<ChannelModel> listChannelModel) {
        DSLVFragmentClicks f = new DSLVFragmentClicks();
        Bundle args = new Bundle();
        args.putInt("headers", 0);
        args.putInt("footers", 0);
        f.setArguments(args);
        f.listChannelModel = listChannelModel;
        return f;
    }

    @Override
    public void onActivityCreated(Bundle savedState) {
        super.onActivityCreated(savedState);

        ListView lv = getListView();
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                                    long arg3) {
            }
        });
        lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,
                                           long arg3) {
                int nextRemoveMode = DragSortController.CLICK_REMOVE;
                if (removeMode == DragSortController.CLICK_REMOVE) {
                    nextRemoveMode = DragSortController.FLING_REMOVE;
                }
                MerchantActivity.getInstance().changeEditMode(nextRemoveMode);
                return true;
            }
        });

        ThemeUtil.setDividerTheme(lv);
    }
}
